<?php

namespace App\Repository\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;

/**
 * Class UserComment.
 *
 * @package namespace App\Repository\Models;
 */
class UserComment extends Model implements Transformable
{
    use TransformableTrait;
    use SoftDeletes;

    protected $table = 'user_comment';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['user_id', 'shop_id', 'order_code', 'overall', 'comment'];

    protected $appends = ['overall_name'];

    public static $overall_map = [
        '1' => '好评',
        '2' => '中评',
        '3' => '差评'
    ];

    public function getOverallNameAttribute()
    {
        if (isset($this->attributes['overall'])) {
            return array_get(self::$overall_map, $this->attributes['overall']);
        }
        return '';
    }

}
